<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 空白页</title>

    <link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link rel="stylesheet" href="__STATIC__/layout/css/zTreeStyle.css" type="text/css">
    <!-- <link href="__STATIC__/layout/css/common.css" rel="stylesheet"> -->
    <style>
        .row {
          
            margin: 0 auto;
        }
      
        #alertmod_table_list_2 {
            top: 900px !important;
        }

        .H_title {
            font-weight: 700;
            color: #333
        }

        .AgencyTitleActive {
            border-bottom: 2px solid #a83838;
            color: #a83838;
            padding-left: 0;
            padding-right: 0;
            border-left: 1px solid #ccc;
            border-right: 1px solid #ccc
        }
        .H_right{ border-right: 1px solid #ccc}
        .padding_lr {
            padding-left: 0;
            padding-right: 0
        }

        /*  select{width: 150px ;height:22px;}*/

        /*  .quedingbtn button{text-align: center;margin-right: 5px;margin-left: 0}*/

        .agencyM_table tr td a:hover {
            text-decoration: underline;
        }

        .agencyM_table tr td span {
            font-size: 12px;
            margin: 0 5px 0 5px;
        }

        .agencyM_table tr td .add_import {
            font-size: 12px;
            color: red;
        }

        .agencyM_table tbody tr td .textareaInfo {
            width: 100%;
            max-height: 50px;
            /*自动适应父布局宽度*/
            overflow: auto;
            word-break: break-all;
        }

        .agencyM_table tbody tr td ul li a {
            display: inline-block;
            margin: 0 8px;
            font-weight: bold;
        }

        .agencyM_table tbody .this_tableInfo_alert {
            display: none;
        }

        .H_title {
            cursor: pointer;
        }

        .Agencycontent {
            display: none;
        }

        .AgencycontentActive {
            display: block
        }

        .trBackgroundColor {
            background: #c5e1fe
        }

     
    </style>
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <!-- layer javascript -->
    <script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
</head>

<body class="white-bg" style="color:#333;padding:3px;font-size: 13px">
<div class="row border-bottom white-bg">
    <h2 class="col-md-12 border_S padding_lr H_title title_color text-center">
        <div class="col-md-4 {if $import!=1}AgencyTitleActive{/if}"><a href="{:url('index')}" style="color:inherit;font-size: 16px">全部经销商</a></div>
        <div class="col-md-4 H_right {if $import==1}AgencyTitleActive{/if}"><a href="{:url('index',array('import'=>1))}" style="color:inherit;font-size: 16px">重点经销商</a></div>
        <div class="col-md-4"><a href="{:url('lianluoagency')}" style="color:inherit;font-size: 16px">联络经销商</a></div>
    </h2>
</div>
<div id="chooseTitle">
    {if $import != 1}
    <div class="Agencycontent AgencycontentActive">
        <div class="col-md-12" style="padding: 10px 0;font-size:14px">
            <a href="{:url('addAgency')}" class="btn btn-sm btn-primary">新增经销商</a>
            <button class="btn btn-sm btn-primary mapShowAllAgency">在地图上显示所有经销商</button>
            <button class="btn btn-sm btn-primary mapShowIpAgency">在地图上显示所有重点经销商</button>
            <button class="btn btn-sm btn-primary ZoneTree">批量导入及更新经销商信息</button>
            <button class="btn btn-sm btn-primary rubish" style="position: absolute;right: 20px;top:8px" id="isdel">回收站</button>
        </div>

        <form role="form" id="form1" class="form-inline" method="get" action="">
        <table class="table table-bordered">
            <tr>
                <td><label for="sn">经销商编号</label></td>
                <td><input type="text" name="sn" value="{$sn}" id="sn" class="form-control"></td>
                <td><label for="zoning">分区</label></td>
                <td><input type="text" name="zoning" value="{$zoning}" id="zoning" class="form-control"></td>
                <td><label for="zoninghead">分区负责人</label></td>
                <td><input type="text" name="zoninghead" value="{$zoninghead}" id="zoninghead" class="form-control"></td>
            </tr>
            <tr>
                <td><label for="title">经销商名称</label></td>
                <td><input type="text" name="title" value="{$title}" id="title" class="form-control"></td>
               
                <td><label for="provice">省份</label></td>
                <td><input type="text" name="provice" value="{$provice}" id="provice" class="form-control"></td>
                <td><label for="provicehead">省份负责人</label></td>
                 <td><input type="text" name="provicehead" value="{$provicehead}" id="provicehead" class="form-control"></td>
            </tr>
               <tr>
                   <td><label for="channeltype">渠道类型</label></td>
                   <td><input type="text" name="channeltype" value="{$channeltype}" id="channeltype" class="form-control"></td>
                   <td><label for="city">城市</label></td>
                   <td><input type="text" name="city" value="{$city}" id="city" class="form-control"></td>
                   <td><label for="cityhead">城市负责人</label></td>
                   <td><input type="text" name="cityhead" value="{$cityhead}" id="cityhead" class="form-control"></td>
               </tr>
            <tr>
                <td><label for="stuff">业务人员</label></td>
                <td colspan="5"><input type="text" name="stuff" value="{$stuff}" id="stuff" class=" form-control"></td>
           </tr>
           <tr>
               <td colspan="6" class="text-center">
                    <button class="btn btn-sm btn-info query" type="submit">查询</button>
            <button class="btn btn-sm btn-info emptyIf" type="reset" id="reset">清空查询条件</button>
            <button class="btn btn-sm btn-info lendExcel">导出导入版Excel</button>
            <button class="btn btn-sm btn-info lendAllExcel">导出完整版Excel</button>
               </td>
           </tr>
      </table>
        </form>
        <script>
            $(function () {
//			    回收站
                $('#isdel').on('click',function () {
                    var index = layer.open({
                        type: 2,
                        title: '经销商-回收站',
//                        area: ['500px', '400px'],
                        fixed: false, //不固定
                        maxmin: true,
                        content: '{:url("isdel")}'
                    });
                    layer.full(index)
                    return false
                })
                $('#reset').on('click',function () {
                    $("#form1 input").each(function(){
                        $(this).val('');
                    });
                    $("#form1 select").each(function(){
                        $(this).val('');
                    });
                    $('#form1').submit()
                    return false
                })
            })
        </script>
        <!-- 表格 -->
        <div class="no-padding">
            <table class="table table-striped table-bordered table-hover bud_hei text-center agencyM_table" style="width: 100%;" id="editable">
                <tr class="info">
                    <th class="text-center">No.</th>
                    <th class="text-center">经销商编号</th>
                    <th class="text-center">经销商</th>
                    <th class="text-center">分销系统数</th>
                    <th class="text-center">分销网点数</th>
                    <th class="text-center">渠道类型</th>
                    <th class="text-center">销售分区</th>
                    <th class="text-center">省份</th>
                    <th class="text-center">城市</th>
                    <th class="text-center">分区负责人</th>
                    <th class="text-center">省份负责人</th>
                    <th class="text-center">城市负责人</th>
                    <th class="text-center">业务人员</th>
                </tr>
                {volist name="data" id="row"}
                <tr class="angency_tableInfo">
                    <td>{$row.id}</td>
                    <td><span>{$row.sn}</span></td>
                    <td><a href="javascript:;" rol="button">{$row.title}</a>
                        <br>
                        {if $row.import==1}
                        <span class="add_import">重点</span>
                        {/if}
                        {if $row.direct==1}
                        <span class="add_span">直营</span>
                        {/if}
                    </td>
                    <td>3</td>
                    <td>36</td>
                    <td>{$row.channeltype}</td>
                    <td>{$row.zoning}</td>
                    <td>{$row.provice}</td>
                    <td>{$row.city}</td>
                    <td>李四</td>
                    <td>测试职员</td>
                    <td>郭建峰</td>
                    <td>
                        <div class="textareaInfo">
                            {if is_array($row.stuff)}
                            {volist name="row.stuff" id="row2"}
                            <span>{$row2}</span>
                            {/volist}
                            {/if}

                        </div>
                    </td>
                </tr>
                <tr class="this_tableInfo_alert">
                    <td colspan="13">
                        <ul style="">
                            <li style="text-align: left;">
                                <a href="{:url('AgencyDetail',array('id'=>$row.id))}" rol="button" class="J_menuItem">查看详情</a>
                                {if $row.import==1}
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="cancelSetImportAgency">取消设置为重点经销商</a>
                                {else}
                                <a href="javascript:;" rol="button" data-id="{$row.id}"
                                   class="setImportAgency">设置为重点经销商</a>
                                {/if}
                                {if $row.direct==1}
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="cancelSetAgency">取消设置为直营经销商</a>
                                {else}
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="setAgency">设置为直营经销商</a>
                                {/if}
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="delAgency">删除经销商</a>
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="batchDel">批量删除经销商及所属系统网点</a>
                                <a href="javascript:;" rol="button" class="ckeckStatement">查看对账单</a>
                                <a href="javascript:;" rol="button">导出对账单明细</a>
                            </li>
                        </ul>
                    </td>
                </tr>
                {/volist}

            </table>
            <div class="row text-center" id="pageText" style="padding: 0;margin: 0;">
					<div class="col-sm-6 text-left"><div class="padding-10 countSize">共{$count}条记录，{$maxpage}页&nbsp;&nbsp;</div></div>
					<div class="col-sm-6 text-right">{$page}</div>
			</div>

        </div>
    </div>
    {else}
    <div class="Agencycontent  AgencycontentActive">
        <div class="padding-10">
            <a href="{:url('addAgency',array('import'=>1))}" class="btn-sm btn-primary btn">新增经销商</a>
            <button class="btn btn-sm btn-primary  mapShowAllAgency">在地图上显示所有经销商</button>
            <button class="btn btn-sm btn-primary ZoneTree">批量导入及更新经销商信息</button>
            <button class="btn btn-sm btn-primary rubish" style="float: right;">回收站</button>
        </div>
        <form role="form" id="form1" class="form-inline" method="get" action="">
            <table class="table table-bordered">
            <tr>
                <td><label for="sn">经销商编号</label></td>
                <td><input type="text" name="sn" value="{$sn}" id="sn" class="form-control"></td>
                <td><label for="zoning">分区</label></td>
                <td><input type="text" name="zoning" value="{$zoning}" id="zoning" class="form-control"></td>
                <td><label for="zoninghead">分区负责人</label></td>
                <td><input type="text" name="zoninghead" value="{$zoninghead}" id="zoninghead" class="form-control"></td>
            </tr>
            <tr>
                <td><label for="title">经销商名称</label></td>
                <td><input type="text" name="title" value="{$title}" id="title" class="form-control"></td>
               
                <td><label for="provice">省份</label></td>
                <td><input type="text" name="provice" value="{$provice}" id="provice" class="form-control"></td>
                <td><label for="provicehead">省份负责人</label></td>
                 <td><input type="text" name="provicehead" value="{$provicehead}" id="provicehead" class="form-control"></td>
            </tr>
               <tr>
                   <td><label for="channeltype">渠道类型</label></td>
                   <td><input type="text" name="channeltype" value="{$channeltype}" id="channeltype" class="form-control"></td>
                   <td><label for="city">城市</label></td>
                   <td><input type="text" name="city" value="{$city}" id="city" class="form-control"></td>
                   <td><label for="cityhead">城市负责人</label></td>
                   <td><input type="text" name="cityhead" value="{$cityhead}" id="cityhead" class="form-control"></td>
               </tr>
            <tr>
                <td><label for="stuff">业务人员</label></td>
                <td colspan="5"><input type="text" name="stuff" value="{$stuff}" id="stuff" class=" form-control"></td>
           </tr>
           <tr>
               <td colspan="6" class="text-center">
                    <button class="btn btn-sm btn-info query" type="submit">查询</button>
            <button class="btn btn-sm btn-info emptyIf" type="reset" id="reset">清空查询条件</button>
            <button class="btn btn-sm btn-info lendExcel">导出导入版Excel</button>
            <button class="btn btn-sm btn-info lendAllExcel">导出完整版Excel</button>
               </td>
           </tr>
      </table>
        </form>
        <script>
            $(function () {
//			    回收站
                $('#isdel').on('click',function () {
                    var index = layer.open({
                        type: 2,
                        title: '经销商-回收站',
//                        area: ['500px', '400px'],
                        fixed: false, //不固定
                        maxmin: true,
                        content: '{:url("isdel")}'
                    });
                    layer.full(index)
                    return false
                })
                $('#reset').on('click',function () {
                    $("#form1 input").each(function(){
                        $(this).val('');
                    });
                    $("#form1 select").each(function(){
                        $(this).val('');
                    });
                    $('#form1').submit()
                    return false
                })
            })
        </script>
        <!-- 表格 -->
        <div class="no-padding">
            <table class="table table-striped table-bordered table-hover bud_hei text-center agencyM_table" style="width: 100%;" id="editable">
                <tr class="info">
                    <th class="text-center">No.</th>
                    <th class="text-center">经销商编号</th>
                    <th class="text-center">经销商</th>
                    <th class="text-center">分销系统数</th>
                    <th class="text-center">分销网点数</th>
                    <th class="text-center">渠道类型</th>
                    <th class="text-center">销售分区</th>
                    <th class="text-center">省份</th>
                    <th class="text-center">城市</th>
                    <th class="text-center">分区负责人</th>
                    <th class="text-center">省份负责人</th>
                    <th class="text-center">城市负责人</th>
                    <th class="text-center">业务人员</th>
                </tr>
                {volist name="data" id="row"}
                <tr class="angency_tableInfo">
                    <td>{$row.id}</td>
                    <td><span>{$row.sn}</span></td>
                    <td><a href="javascript:;" rol="button">{$row.title}</a>
                        <br>
                        {if $row.import==1}
                        <span class="add_import">重点</span>
                        {/if}
                        {if $row.direct==1}
                        <span class="add_span">直营</span>
                        {/if}
                    </td>
                    <td>3</td>
                    <td>36</td>
                    <td>{$row.channeltype}</td>
                    <td>{$row.zoning}</td>
                    <td>{$row.provice}</td>
                    <td>{$row.city}</td>
                    <td>李四</td>
                    <td>测试职员</td>
                    <td>郭建峰</td>
                    <td>
                        <div class="textareaInfo">
                            {if is_array($row.stuff)}
                            {volist name="row.stuff" id="row2"}
                            <span>{$row2}</span>
                            {/volist}
                            {/if}

                        </div>
                    </td>
                </tr>
                <tr class="this_tableInfo_alert">
                    <td colspan="13">
                        <ul style="">
                            <li style="text-align: left;">
                                <a href="{:url('AgencyDetail',array('id'=>$row.id))}" rol="button">查看详情</a>
                                {if $row.import==1}
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="cancelSetImportAgency">取消设置为重点经销商</a>
                                {else}
                                <a href="javascript:;" rol="button" data-id="{$row.id}"
                                   class="setImportAgency">设置为重点经销商</a>
                                {/if}
                                {if $row.direct==1}
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="cancelSetAgency">取消设置为直营经销商</a>
                                {else}
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="setAgency">设置为直营经销商</a>
                                {/if}
                                <a href="javascript:;" rol="button" data-id="{$row.id}" class="delAgency">删除经销商</a>
                                <a href="javascript:;" rol="button">批量删除经销商及所属系统网点</a>
                                <a href="javascript:;" rol="button" class="ckeckStatement">查看对账单</a>
                                <a href="javascript:;" rol="button">导出对账单明细</a>
                            </li>
                        </ul>
                    </td>
                </tr>
                {/volist}

            </table>
            <div class="row text-center" id="pageText" style="padding: 0;margin: 0;">
				<div class="col-sm-6 text-left"><div class="padding-10 countSize">共{$count}条记录，{$maxpage}页&nbsp;&nbsp;</div></div>
				<div class="col-sm-6 text-right">{$page}</div>
			</div>
        </div>
    </div>
    {/if}
</div>
<!-- 表格 -->


<!-- 全局js -->

<script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<!-- <script src="js/plugins/layer/layer.min.js"></script> -->

<!-- 自定义js -->
<!-- <script src="js/hplus.js?v=4.1.0"></script> -->
<!-- <script type="text/javascript" src="js/contabs.js"></script> -->
<!-- Peity -->
<script src="__STATIC__/layout/js/plugins/peity/jquery.peity.min.js"></script>

<!-- 自定义js -->
<script src="__STATIC__/layout/js/content.js?v=1.0.0"></script>
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>

<!-- ztree -->
<script type="text/javascript" src="__STATIC__/layout/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="__STATIC__/layout/js/jquery.ztree.excheck.js"></script>
<script src="__STATIC__/layout/js/contabs_sub.js"></script>
<!-- <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script> -->
<!--统计代码，可删除-->
<script>
    $(document).ready(function () {

        /*关闭弹出框方法*/
        var del_this = $(".del_this");
        console.log(del_this.length)
        for (var i = 0, len = del_this.length; i < len; i++) {
            del_this[i].onclick = function () {
                $(this).parent().parent().parent().hide()
            }
        }
        ;
        $("").click(function () {

        })
        $(".angency_tableInfo>td>a").click(function () {
            $(this).parents("tr").next(".this_tableInfo_alert").toggle().siblings(".this_tableInfo_alert").hide();
            $(this).parents("tr").addClass("trBackgroundColor").siblings("tr").removeClass("trBackgroundColor");
        })

        /*设置重点经销商*/
        $(".agencyM_table tr td .setImportAgency").click(function () {
            var id = $(this).data('id')
            $.ajax({
                'type': 'get',
                'url': "{:url('setImport')}",
                'data': {id: id},
                'dataType': 'json',
                'success': function (data) {
                    if (data.flag == true) {
                        swal({title:"", text:"设置成功!", type:"success"},function () {
                            history.go(0)
                        });

                    } else {
                        swal("", "设置失败!", "error");
                    }
                }
            })
        });
        $(".agencyM_table tr td .cancelSetImportAgency").click(function () {
            var id = $(this).data('id')
            $.ajax({
                'type': 'get',
                'url': "{:url('unsetImport')}",
                'data': {id: id},
                'dataType': 'json',
                'success': function (data) {
                    if (data.flag == true) {
                        swal({title:"", text:"设置成功!", type:"success"},function () {
                            history.go(0)
                        });
                    } else {
                        swal("", "设置失败!", "error");
                    }
                }
            })
        });
        $(".agencyM_table tr td .cancelSetAgency").click(function () {
            var id = $(this).data('id')
            $.ajax({
                'type': 'get',
                'url': "{:url('unsetDirect')}",
                'data': {id: id},
                'dataType': 'json',
                'success': function (data) {
                    if (data.flag == true) {
                        swal({title:"", text:"取消设置成功!", type:"success"},function () {
                            history.go(0)
                        });
                    } else {
                        swal("", "取消设置失败!", "error");
                    }
                }
            })

        });
        $(".agencyM_table tr td .setAgency").click(function () {
            var id = $(this).data('id')
            $.ajax({
                'type': 'get',
                'url': "{:url('setDirect')}",
                'data': {id: id},
                'dataType': 'json',
                'success': function (data) {
                    if (data.flag == true) {
                        swal({title:"", text:"取消设置成功!", type:"success"},function () {
                            history.go(0)
                        });
                    } else {
                        swal("", "设置失败!", "error");
                    }
                }
            })

        });

        //删除经销商
        $(".agencyM_table tr td .delAgency").click(function () {
            var id = $(this).data('id')
            swal({
                title: "确定删除吗？",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "返回"
            },function (ff) {
                if(ff){
                    $.ajax({
                        'type': 'post',
                        'url': "{:url('delete')}",
                        'data': {id: id},
                        'dataType': 'json',
                        'success': function (data) {
                            if (data.success == true) {
                                swal({title:"", text:"删除成功!", type:"success"},function () {
                                    history.go(0)
                                });
                            } else {
                                swal("", "删除失败!", "error");
                            }
                        }
                    })
                }

            });

        });
        //批量删除经销商及其下属系统网点
        $(".agencyM_table tr td .batchDel").click(function () {
            var id = $(this).data('id')
            swal({
                title: "确定删除吗？",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "返回"
            },function (ff) {
                if(ff){
                    $.ajax({
                        'type': 'post',
                        'url': "{:url('batchDel')}",
                        'data': {id: id},
                        'dataType': 'json',
                        'success': function (data) {
                            if (data.success == true) {
                                swal({title:"", text:"删除成功!", type:"success"},function () {
                                    history.go(0)
                                });
                            } else {
                                swal("", "删除失败!", "error");
                            }
                        }
                    })
                }

            });

        });

        /*查看对账单*/
        $(".ckeckStatement").click(function () {
            $(this).attr("href", '{:url("AgencyStatement")}')
        })

        //在地图上显示网点
        $('.mapShowAllAgency').click(function () {
            layer.open({
                type: 2,
                title: '&nbsp;',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['800px', '500px'],
                content: '{:url("mapShow")}'
            })
            return false
        })
        //在地图上显示所有重点网点
        $('.mapShowIpAgency').click(function () {
            layer.open({
                type: 2,
                title: '&nbsp;',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['800px', '500px'],
                content: '{:url("mapShow",["import"=>1])}'
            })
            return false
        })
    });
</script>
</body>

</html>